//
//	 ______    ______    ______    
//	/\  __ \  /\  ___\  /\  ___\   
//	\ \  __<  \ \  __\_ \ \  __\_ 
//	 \ \_____\ \ \_____\ \ \_____\ 
//	  \/_____/  \/_____/  \/_____/ 
//
//	Powered by BeeFramework
//
//
//  AppTabbar_iPhone.m
//  Walker
//
//  Created by he chao on 3/10/14.
//    Copyright (c) 2014 leon. All rights reserved.
//

#import "AppTabbar_iPhone.h"

#pragma mark -
//DEF_PACKAGE(BeePackage_UI,AppTabbar_iPhone, tabbar)

@implementation AppTabbar_iPhone
//DEF_SINGLETON( AppTabbar_iPhone )

SUPPORT_RESOURCE_LOADING( YES )


- (void)load
{
	[super load];
    
    [self selectTab0];
    

}

- (void)unload
{
	[super unload];
}

ON_NOTIFICATION(notification){
//    if ([notification is:kBadge]) {
//        [self setBadgeStatus];
//    }
}

- (void)setBadgeStatus{
    for (int i = 0; i < 4; i++) {
        $([NSString stringWithFormat:@"#badge-bg%d",i]).HIDE();
    }
    if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"roadBadge"] boolValue]) {
        $(@"#badge-bg0").SHOW();
    }
    if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"activityBadge"] boolValue]) {
        $(@"#badge-bg1").SHOW();
    }
    if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"friendBadge"] boolValue]) {
        $(@"#badge-bg2").SHOW();
    }
    if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"teamBadge"] boolValue]) {
        $(@"#badge-bg3").SHOW();
    }
    
    self.RELAYOUT();
}

#pragma mark Signal

- (void)deselectAll{
    for (int i = 0; i < 4; i++) {
        $([NSString stringWithFormat:@"#img_tab%d",i]).HIDE();
        $([NSString stringWithFormat:@"#btn_tab%d",i]).UNSELECT();
        BeeUIQuery *query = (BeeUIQuery *)$([NSString stringWithFormat:@"#lb_tab%d",i]);
        BeeUILabel *lb = query.object[0];
        [lb setTextColor:RGB(102, 102, 102)];
    }
    [self setBadgeStatus];
}


- (void)selectTab0{
    [self deselectAll];
    
    $(@"#img_tab0").SHOW();
	$(@"#btn_tab0").SELECT();
    BeeUIQuery *query = (BeeUIQuery *)$(@"#lb_tab0");
    BeeUILabel *lb = query.object[0];
    [lb setTextColor:RGB(9, 148, 245)];
    
    
    [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"roadBadge"];
    $(@"#badge-bg0").HIDE();
    
    
    self.RELAYOUT();
    
}

- (void)selectTab1{
    [self deselectAll];
    
    $(@"#img_tab1").SHOW();
	$(@"#btn_tab1").SELECT();
    
    BeeUIQuery *query = (BeeUIQuery *)$(@"#lb_tab1");
    BeeUILabel *lb = query.object[0];
    [lb setTextColor:RGB(9, 148, 245)];
    
    [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"activityBadge"];
    $(@"#badge-bg1").HIDE();
    
    self.RELAYOUT();
    

}

- (void)selectTab2{
    [self deselectAll];
    
    $(@"#img_tab2").SHOW();
	$(@"#btn_tab2").SELECT();
    
    BeeUIQuery *query = (BeeUIQuery *)$(@"#lb_tab2");
    BeeUILabel *lb = query.object[0];
    [lb setTextColor:RGB(9, 148, 245)];
    
    [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"friendBadge"];
    $(@"#badge-bg2").HIDE();
    
    self.RELAYOUT();
    


}

- (void)selectTab3{
    [self deselectAll];
    
    $(@"#img_tab3").SHOW();
	$(@"#btn_tab3").SELECT();
    
    BeeUIQuery *query = (BeeUIQuery *)$(@"#lb_tab3");
    BeeUILabel *lb = query.object[0];
    [lb setTextColor:RGB(9, 148, 245)];
    
    [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"teamBadge"];
    $(@"#badge-bg3").HIDE();
    
    self.RELAYOUT();
    

}

@end
